// import { asyncRoutes } from '@/router';

// export function convertRouter(routers) {
//   return routers.map((route) => {
//     return setRoutes(route, asyncRoutes);
//   });
// }
import router from '@/router';

function hasPermission(permissions, route) {
  return true;
}

export function filterAsyncRoutes(routes, permissions) {
  const finallyRoutes = [];
  routes.forEach((route) => {
    const item = { ...route };
    if (hasPermission(permissions, item)) {
      if (item.children) {
        item.children = filterAsyncRoutes(item.children, permissions);
      }
      finallyRoutes.push(item);
    }
  });
  return finallyRoutes;
}

// const flatRouteList = (routes) => {
//   if (routes.length === 0) return [];
//   let result = [];
//   routes.forEach((route) => {
//     const item = { ...route };
//     if (route.children) {
//       result = result.concat(flatRouteList(route.children));
//     }
//     delete item.children;
//     result.push(item);
//   });
//   return result;
// };

export const checkRoute = (routePath) => {
  const routeList = router.getRoutes();
  return routeList.find((route) => route.path === routePath);
};
